package com.nulldev.util.net.experimental.groupedudp;

import com.nulldev.util.crypto.encryptAPI.manage.EncryptAPI;

public class Encryptor {
	private final String password;
	
	public static final Encryptor DUMMY = new Encryptor();
	
	public Encryptor() {
		this.password = null;
	}
	
	public Encryptor(final String password) {
		this.password = password;
	}
	
	public synchronized byte[] encrypt(final byte[] data) {
		if (this.password == null) {
			return data;
		}
		return EncryptAPI.getEncryptorForEncryption("AES").encryptBytes(data, this.password);
	}
	
	public synchronized byte[] decrypt(final byte[] data) {
		if (this.password == null) {
			return data;
		}
		return EncryptAPI.getEncryptorForEncryption("AES").decryptBytes(data, this.password);
	}
}
